package com.scy.utils;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author 司晨雨
 * @date 2020/5/4 23:22
 * @description
 */
public class ConnectionUtils {

    private ThreadLocal<Connection> threadLocal = new ThreadLocal<Connection>();

    public Connection getCurrentThreadConn() throws SQLException {
        Connection connection = threadLocal.get();
        if (connection == null) {
            connection = DruidUtils.getInstance().getConnection();
            threadLocal.set(connection);
        }
        return  connection;
    }

}
